*** Summary Statistics Table

use "$datapath\001_nlsy_child_mother_cog.dta", clear

replace wage_hour_beforebirth_mom = . if wage_hour_beforebirth_mom==0

** Delete top bunching
drop if hours == 2080

** Positive hours worked
gen worked_zerohours3years = (hrs_worked_1year==0 & hrs_worked_2year==0 & hrs_worked_3year==0)

label var math "PIAT Math"
label var recog "PIAT Reading Recognition"

label var hours "Mother's average hours worked in 3 first years"
label var top_bunch_hours "Mother's average hours worked in 3 first years = 2080"
label var worked_zerohours3years "Mother worked 0 hours in 3 first years"

label var age_cog "Child's age at test (in months)"
label var male "Sex of child (male=1, female=0)"
label var birth_order "Birth order of child"
label var hispanic "Child is Hispanic"
label var black "Child is Black"


label var afqt_mom_orig "Mother's AFQT score"

label var wage_hour_beforebirth_mom "Mother's wage year prior to the birth of the child"

label var hs_ls_mom "Mother's education less than high school" 
label var hs_mom "Mother's education completed high school" 
label var col_sm_mom "Mother's education some college" 
label var col_mom "Mother's education completed college" 
label var col_pl_mom "Mother's education more than college" 

label var mother_teen "Mother's age less than 20 years old"
label var mother_2024 "Mother's age 20 to 24 years old"
label var mother_2529 "Mother's age 25 to 29 years old"
label var mother_3034 "Mother's age 30 to 34 years old"
label var mother_old  "Mother's age 35 years old or more"


label var spouse_atbirth "Mother's spouse present"
label var hgc_birth_spouse_mom "Mother's spouse highest grade"

label var famsize "Family size"
label var north "Lives in north region"
label var northcentral "Lives in north-central region"
label var south "Lives in south region"
label var west  "Lives in west region"


estpost sum recog math   ///
hours  ///
worked_zerohours3years ///
afqt_mom_orig wage_hour_beforebirth_mom ///
hs_ls_mom hs_mom col_sm_mom col_mom col_pl_mom ///
mother_teen mother_2024 mother_2529 mother_3034 mother_old  ///
spouse_atbirth hgc_birth_spouse_mom ///
age_cog male birth_order hispanic black ///
famsize north northcentral south west  


est store sum_stats
 
esttab sum_stats using "$outpath/002_TableSummaryStats.tex", replace ///
refcat(recog "\textbf{\emph{Outcome variables}" ///
hours "\textbf{\emph{Treatment variable}}"  ///
worked_zerohours3years "\textbf{\emph{Bunching variables}}" ///
afqt_mom_orig "\textbf{\emph{Control variables}}" ///
, nolabel) ///
cells("mean(fmt(%12.2fc)) sd(fmt(%12.2fc))") label mlabels(,none) ///
nonumber f alignment(S) booktabs obslast ///
collabels(Mean Std.Dev.)
